package com.bw.servlet;

import com.bw.dao.CarDao;
import com.bw.pojo.Car;
import lombok.SneakyThrows;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/***************************
 FileAction:

 CreateTime:2022-04-11 10:32
 Author:Aaking-aline
 ****************************/
@WebServlet("/SelectCarByLimit")
public class SelectCarByLimit extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    @SneakyThrows
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String page = request.getParameter("page");

        int number = new CarDao().selectNum();

        List<Car> list = new CarDao().selectCarByLimit(page);

        request.setAttribute("list",list);
        request.setAttribute("page",page);
        request.setAttribute("number",number);

        request.getRequestDispatcher("message.jsp").forward(request,response);
    }
}
